$date_now=(Get-Date -Format "yyyy_MM_dd_HH_mm_ss")

$log_name = "avcodec_log_$date_now.log"

if (-not ((hdc $hdc_cn shell "hilog -w query") -match "No running persistent task")) {
    hdc $hdc_cn shell "hilog -w stop"
}
hdc $hdc_cn shell "rm /data/log/hilog/*"
hdc $hdc_cn shell "hilog -b D -D 0xd002b30,0xd002b32"
hdc $hdc_cn shell param set persist.sys.hilog.binary.on false
hdc $hdc_cn shell param set hcodec.debug 1
hdc $hdc_cn shell "hilog -Q domainoff"
hdc $hdc_cn shell "hilog -Q pidoff"
hdc $hdc_cn shell "hilog -p off"
hdc $hdc_cn shell "hilog -w start $domain_filter -f $log_name -l 512M -m none"

Pause

$log_name_ = (hdc $hdc_cn shell "cd /data/log/hilog/; ls $log_name*")
$log_name_ -match "avcodec_log_.*.log" | Out-Null
$output_name = $Matches[0]
if ($null -ne $trace_file_dir) {
    $output_dir = "$trace_file_dir\$trace_info\"
}

Write-Output $log_name_
hdc $hdc_cn shell "hilog -w stop"
hdc $hdc_cn file recv "/data/log/hilog/$log_name_" $output_dir
hdc $hdc_cn shell "hilog -r"

Rename-Item -Path "$output_dir$log_name_" -NewName "$output_name"